package logic

import (
	"collection_srv/collection"
	"collection_srv/internal/dao"
	"collection_srv/internal/svc"
	"collection_srv/model"
	"context"
	"github.com/zeromicro/go-zero/core/logx"
)

type GlucoseLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewGlucoseLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GlucoseLogic {
	return &GlucoseLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 血压测试数据
func (l *GlucoseLogic) Glucose(in *collection.GlucoseRequest) (*collection.GlucoseResponse, error) {
	var result model.BloodGlucoseMeterData // 体温数据表
	//发送者发送消息
	dao.GSendData(uint64(in.DeviceId), uint64(in.UserId), &result)
	//[订阅者] 接收数据
	dao.GMessageCallback(uint64(in.DeviceId), uint64(in.UserId), &result)
	return &collection.GlucoseResponse{Msg: "数据采集成功"}, nil
}
